package com.karson.front.consumer;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.karson.common.config.rabbitmq.RabbitConfig;
import com.karson.common.dto.rabbitmq.UserModelDTO;
import com.karson.service.service.UserEntityWeightService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author ZKS
 */
@Component
public class ChangeUserModelConsumer {
    @Autowired
    private UserEntityWeightService userEntityWeightService;

    @RabbitListener(queues = RabbitConfig.QUEUE_USER_MODEL)
    public void recordUserProfile(String message) {
        JSONObject json = JSONUtil.parseObj(message);
        UserModelDTO messageDto = json.toBean(UserModelDTO.class);
        userEntityWeightService.updateUserInterestWeight(messageDto);
    }
}
